Ext.define('xyc.view.Accept', {
    extend: 'Process',
    xtype: 'accept',
    initialize: function () {
        this.callParent();
        this.down('toolbar').add([
            { xtype: 'spacer' },
            {
                text: '接收',
                scope: this,
                handler: function () {
                    Ext.Ajax.request({
                        url: server + '/ext/com.cinsea.mobile.ext.XycAction?action=acceptchange',
                        params: {processid: this.processid},
                        scope: this,
                        success: function (response, opts) {
                            if (response.responseText == 'success') {
                                this.prevCard.refresh();
                                this.getParent().setActiveItem(this.prevCard, {
                                    type: 'slide',
                                    reverse: true,
                                    scope: this,
                                    after: function () {
                                        this.destroy();
                                    }
                                });
                            }
                            else
                                Ext.Msg.alert(response.responseText);
                        },
                        failure: function (response, opts) {
                            Ext.Msg.alert('网络异常');
                        }
                    });

                }
            },
            {
                text: '拒绝',
                scope: this,
                handler: function () {
                    Ext.Ajax.request({
                        url: server + '/ext/com.cinsea.mobile.ext.XycAction?action=rejectchange',
                        params: {processid: this.processid},
                        scope: this,
                        success: function (response, opts) {
                            if (response.responseText == 'success') {
                                this.prevCard.refresh();
                                this.getParent().setActiveItem(this.prevCard, {
                                    type: 'slide',
                                    reverse: true,
                                    scope: this,
                                    after: function () {
                                        this.destroy();
                                    }
                                });
                            }
                            else
                                Ext.Msg.alert(response.responseText);
                        },
                        failure: function (response, opts) {
                            Ext.Msg.alert('网络异常');
                        }
                    });

                }
            }
        ])
    }
});